package net.vanchu.mortgagecalculator.mortgage.resultShow;

import android.support.v4.view.PagerAdapter;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;

/**
 * Created by Granton on 2016/12/26.
 */
public class SingleWayPageAdapter extends PagerAdapter {

    private RecyclerView[] recyclerViews;

    private SingleWayResultDataAdapter[] dataAdapters;

    public SingleWayPageAdapter(RecyclerView[] recyclerViews, SingleWayResultDataAdapter[] dataAdapters) {
        this.recyclerViews = recyclerViews;
        this.dataAdapters = dataAdapters;
    }

    @Override
    public Object instantiateItem(ViewGroup container, int position) {
        RecyclerView recyclerView = recyclerViews[position];
        recyclerView.setAdapter(dataAdapters[position]);
        container.addView(recyclerView);
        return recyclerView;
    }

    @Override
    public int getCount() {
        return 2;
    }

    @Override
    public boolean isViewFromObject(View view, Object object) {
        return view == object;
    }
}